package com.abbcc.module.admin;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;

import com.abbcc.action.BaseAction;
import com.abbcc.models.TdQx;
import com.abbcc.models.TdUqx;
import com.abbcc.service.QxService;

public class QxAction extends BaseAction<TdQx>{
	private int userId;
	public int[] menus;
	@Autowired
	QxService qxService;
	public String list(){
		DetachedCriteria dc = DetachedCriteria.forClass(entityClass);
		deposit("qxlist", qxService.findAllByCriteria(dc));
		return LIST;
	}
	public String update(){
		String hql = "delete TdUqx where userId=?";
		baseService.bulkUpdate(hql, userId);
		for(int s : menus){
			TdQx tq = new TdQx();
			qxService.load(tq, s);
			TdUqx tu = new TdUqx();
			tu.setQxAction(tq.getQxAction());
			tu.setQxName(tq.getQxName());
			tu.setUserId(userId);
			baseService.save(tu);
		}
		result = "修改成功!";
		return list();
	}
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	
}
